package com.llstudio.foodtogo.domain;

import java.time.LocalDateTime;

public class PendingOrder {
    private Address deliveryAddress;
    private LocalDateTime deliveryTime;

    public boolean updateDeliveryInfo(
            RestaurantRepository restaurantRepository,
            Address deliveryAddress,
            LocalDateTime deliveryTime) {
        if (deliveryTime.isBefore(LocalDateTime.now().plusHours(1L))) return false;
        if (restaurantRepository.isRestaurantAvailable(deliveryAddress, deliveryTime)) {
            this.deliveryAddress = deliveryAddress;
            this.deliveryTime = deliveryTime;
            return true;
        }
        return false;
    }

    public Address getDeliveryAddress() {
        return deliveryAddress;
    }

    public LocalDateTime getDeliveryTime() {
        return deliveryTime;
    }
}
